import pandas as pd

# 读取csv文件，并只取title，rating，status，date，anime_type字段
df = pd.read_csv('../static/data/anime.csv')
df = df[['title','rating','status','date','anime_type']]
# 将rating字段中的'分'替换为空，并转换为float类型
df['rating'] = df['rating'].apply(lambda x: x.replace('分','')).astype('float')
# 将status字段中的'连载'替换为空，如果为空则替换为'无'
df['status'] = df['status'].apply(lambda x: x.replace('连载：',''))
df['status'] = df['status'].apply(lambda x: '无' if x == '' else x)
# 将date字段中的'上映'替换为空，如果为空则替换为'无'
df['date'] = df['date'].apply(lambda x: x.replace('上映：',''))
df['date'] = df['date'].apply(lambda x: x.split('-')[0])
df['date'] = df['date'].apply(lambda x: '无' if x == '' else x)
df['date'] = df['date'].apply(lambda x: '无' if x == '0000' else x)
# 将处理后的数据写入csv文件
df.to_csv('../static/data/anime_clean.csv',index=False)